package cn.bdqn.controller;

import cn.bdqn.pojo.Question;
import cn.bdqn.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * @author 正文
 * @date 2020/7/3 - 17:24
 */
//问题反馈
@Controller
public class QuestionController {
    @Autowired
    private QuestionService questionService;
    //问题提交成功后返回我的积分页面
    @RequestMapping("/addusr")
    public String add(Question question, HttpServletRequest request, HttpSession session1) {
        Integer id = (Integer) request.getSession().getAttribute("id");
        question.setFeedbackid(id);
        question.setTime(new Date());
        int sum= questionService.add(question);
        session1.setAttribute("sum",sum);
        return "redirect:/totest";
    }
    //跳转问题反馈页面
    @RequestMapping("/totest")
    public String tost(HttpSession session1,Model model){
        Integer si= (Integer) session1.getAttribute("sum");
        model.addAttribute("sum",si);
        return "personal/beadded";
    }
    //跳转问题反馈页面
    @RequestMapping("/totest1")
    public String tost1(){
        return "personal/beadded";
    }
}
